#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using LL = long long;

unordered_map<LL, LL> f;

LL clac(LL n){
    if(f[n] != 0) return f[n];

    f[n] = clac(n/2) + clac(n/3);
    return f[n];
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    f[0] = 1;
    LL n;
    cin >> n;

    clac(n);

    cout << f[n] << '\n';


    return 0;
}